<template>
  <section>
    <div class="custorm--modelbox graphicaudio-edit">
      <!-- <upload-model ref="audio" :saveChangeEvt="audioSaveChange" :uploadType="audioConfig.type" :config="audioConfig"></upload-model>
        <upload-model ref="upload" :saveChangeEvt="uploadSaveChange" :uploadType="uploadConfig.type" :config="uploadConfig"></upload-model> -->
      <renohome-right-nav :custormItemData="custormItemData" @rightNavChange="rightNavChange" showChange="1"></renohome-right-nav>
      <section v-if="nrActive">
        <div class="edit-form-item">
          <div class="form-label">音频选择</div>
          <div v-if="custormItemData.params.audio.file_path==''" class="uploadSource" @click="uploadtoggle('audio')"><i class="el-icon-plus" style="font-size: 36px;line-height:80px;"></i></div>
          <div v-if="custormItemData.params.audio.file_path!=''" class="my-uploadSource flex-row flex-align-c" @click="uploadtoggle('audio')">
            <i class="el-icon-caret-right" style="margin-right:20px;font-size:30px;"></i>
            <div class="ellipsis" style="color:rgb(218, 217, 217)">{{custormItemData.params.audioname}}</div>
            <i class="el-icon-circle-close  my-close-light" @click.stop="delAudio"></i>
          </div>
        </div>

        <div class="edit-form-item" v-if="custormItemData.style.display==1 || custormItemData.style.display==2">
          <div class="form-label">颜色选择</div>
          <el-form label-width="50px" size="mini" class="goodsset" label-position="right" style="margin-top:8px;">
            <el-form-item label="颜色">
              <div class="flex-row">
                <el-color-picker v-model="custormItemData.params.color"></el-color-picker>
                <div class="showcolor">{{custormItemData.params.color}}</div>
              </div>
            </el-form-item>
          </el-form>
        </div>
        <div class="es-form-item">
          <div class="form-label">标题文字</div>
          <div style="padding-top: 20px;">
            <div>
              <div class="item-inner " v-if="custormItemData.style.display==3 || custormItemData.style.display==4"><span class="labeltext">图片</span>
                <div typetext="图片" show="0" class="small" style="align-self: start;">
                  <div class="uploadSource solid"><i class="delete ivu-icon iconfont icon-input_clear" style="font-size: 16px;"></i>
                    <div class="img" @click="uploadtoggle('image')" :style="{'background-image':`url(${getPath(custormItemData.params.thumb.file_path)})`,'height':'50px','background-repeat':'no-repeat','background-size':'cover','background-position':'50%'}"></div>
                  </div>
                </div>
              </div>

              <div class="item-inner " v-if="custormItemData.style.display==1 || custormItemData.style.display==2">
                <span class="labeltext">名称</span>
                <el-input v-model="custormItemData.params.title" size="mini" style="width: 0;flex-grow: 1;"></el-input>
              </div>
              <!-- <div class="item-inner ">
                <span class="labeltext">作者</span>
                <el-input
                  v-model="custormItemData.params.subtitle"
                  size="mini"
                  style="width: 0;flex-grow: 1;"
                ></el-input>
              </div> -->
            </div>
          </div>
        </div>
      </section>
      <section v-if="fgActive" class="flex-col">
        <div style="overflow: hidden;" class="audio-item" @click="changeAudio(1)" v-bind:class="{active:custormItemData.style.display==1}">
          <div class="es-audio style1 flex-row" style="margin-top: 5px; margin-bottom: 5px;">
            <div class="img">
              <svg-icon icon-class="bofang" />
            </div>
            <div class="content">
              <div class="name" style="color: rgb(51, 51, 51);">主标题</div>
              <div class="cap-slider">
                <div class="cap-slider__bar">
                  <span class="cap-slider__finished-portion" style="background-color: rgb(68, 187, 0); width: 0%;"></span>
                  <span class="cap-slider__pivot" style="background-color: rgb(255, 255, 255); left: 0%; margin-left: -2px;"></span>
                </div>
              </div>
            </div>
          </div>
        </div>
        <p class="text-center">风格一</p>
        <div style="overflow: hidden;" class="audio-item" @click="changeAudio(2)" v-bind:class="{active:custormItemData.style.display==2}">
          <div class="es-audio style2 flex-row flex-align-c" style="margin-top: 5px; margin-bottom: 5px;">
            <svg-icon icon-class="bofang" />
            <div class="content">
              <div class="name" style="color: rgb(51, 51, 51);">主标题</div>
            </div>
          </div>
        </div>
        <p class="text-center">风格二</p>
        <div style="overflow: hidden;" class="audio-item" @click="changeAudio(3)" v-bind:class="{active:custormItemData.style.display==3}">
          <div class="es-audio style3" style="margin-top: 5px; margin-bottom: 5px;">
            <div class="img"><img :src="getPath('default_picture.png')" draggable="false"></div>
            <img :src="getPath('audio1.png')" alt="" class="audio1">
          </div>
        </div>
        <p class="text-center">风格三</p>
        <div style="overflow: hidden;" class="audio-item" @click="changeAudio(4)" v-bind:class="{active:custormItemData.style.display==4}">
          <div class="es-audio style4" style="margin-top: 5px; margin-bottom: 5px;">
            <div class="img"><img :src="getPath('default_picture.png')"></div>
            <img :src="getPath('audio2.png')" alt="" class="audio2">
          </div>
        </div>
        <p class="text-center">风格四</p>
      </section>
    </div>
  </section>
</template>

<script>
import defaultConfig from './utils/editConfig'
export default {
  mixins: [defaultConfig.mixins],
  props: {
    defaultConfig: {
      type: Object,
      default: function() {
        return defaultConfig
      }
    }
  },
  data() {
    return {
      nrActive: true,
      fgActive: false,
      tabType: ['home', 'ather']
    }
  },
  components: {

  },
  watch: {

  },
  mounted() { },
  methods: {
    delAudio() {
      this.custormItemData.params.audio = ''
      this.custormItemData.params.audioname = ''
    },
    changeAudio(e) {
      this.custormItemData.style.display = e
    },
    uploadFileCallBack(files) {
      const { key, type: [file_type] } = files
      if (key === 'ChooseFiles') {
        const { displayData: [file_path] } = files
        if (file_path) {
          if (file_type === 'image') {
            this.custormItemData.params.thumb = file_path
          } else if (file_type === 'audio') {
            this.custormItemData.params.audio = file_path
            this.custormItemData.params.audioname = file_path.file_name
          }
        }
      }
    },
    uploadtoggle(type) {
      this.output({ type: type, params: { editKey: this.custormItemData.key } })
    }
  }
}
</script>

<style lang="scss" scoped>
.custorm--modelbox.graphicaudio-edit {
  .audio-item {
    margin: 15px 8px;
    padding: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 3px;
  }

  .audio-item.active {
    border: 1px solid #409eff;
  }

  .uploadSource {
    width: 80px;
    height: 80px;
    margin-right: 10px;
    border: 1px dashed #ededed;
    text-align: center;
    color: #dad9d9;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    position: relative;
    cursor: pointer;
  }

  .es-audio {
    border: 1px solid #eee;
    padding: 0 15px 0 10px;
    box-sizing: border-box;
    position: relative;
    margin: 0 12px;
    overflow: hidden;
    background: #fff;
    line-height: 1.5;
  }

  .es-audio .img {
    img {
      width: 100%;
      height: 100%;
      max-width: 100%;
      max-height: 100%;
    }
  }

  // 1
  .es-audio.style1 {
    padding: 0;
    height: 60px;

    svg {
      width: 40px;
      height: 40px;
      margin: 9.5px 0 0 9.5px;
      max-width: 100%;
      max-height: 100%;
    }

    .content {
      height: 30px;
      line-height: 30px;
      font-size: 14px;
      padding-left: 18px;
      color: #333;
      flex: 1;

      .cap-slider {
        background-color: #f2f2f2;
        width: 90%;

        .cap-slider__bar {
          position: relative;
          margin: 0 8px 0 0;
          height: 2px;
          border-radius: 0;
          background-color: #f2f2f2;

          .cap-slider__pivot {
            position: absolute;
            top: 50%;
            width: 14px;
            height: 14px;
            border: 1px solid #e5e5e5;
            border-radius: 50%;
            transform: translate3d(0, -50%, 0);
          }

          .cap-slider__pivot::after {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin: auto;
            width: 4px;
            height: 4px;
            border-radius: 4px;
            background: #409eff;
          }
        }
      }
    }
  }

  // 2
  .es-audio.style2 {
    padding: 0;
    height: 46px;
    padding: 0 12px;

    svg {
      width: 25px;
      height: 25px;
      max-width: 100%;
      max-height: 100%;
    }

    .content {
      float: left;
      height: 46px;
      display: -webkit-box;
      display: -ms-flexbox;
      display: -webkit-flex;
      display: flex;
      -webkit-box-orient: vertical;
      -webkit-box-direction: normal;
      -ms-flex-direction: column;
      flex-direction: column;
      -webkit-flex-direction: column;
      -webkit-box-pack: center;
      -webkit-justify-content: center;
      -ms-flex-pack: center;
      justify-content: center;
      margin-left: 12px;
    }
  }

  // 3
  .es-audio.style3 {
    padding: 0;
    border: 0;

    .img {
      float: left;
      margin-right: 10px;
      width: 48px;
      height: 48px;
    }

    .audio1 {
      width: 136px;
      display: block;
    }
  }

  // 4
  .es-audio.style4 {
    padding: 0;
    border: 0;

    .img {
      float: right;
      margin-left: 10px;
      width: 48px;
      height: 48px;
    }

    .audio2 {
      width: 136px;
      display: block;
      float: right;
    }
  }

  //列表开始
  .es-form-item {
    border-bottom: 5px solid #f6f7f9;
    padding: 20px 23px;
    font-size: 12px;

    .uploadSource {
      background: #fff;
      cursor: pointer;
    }

    .uploadSource {
      width: 50px;
      height: 50px;
      line-height: 50px;
      margin-right: 0;
      border: 1px dashed #ededed;
      text-align: center;
      color: #dad9d9;
      background-size: 100% 100%;
      background-repeat: no-repeat;
      float: left;
      position: relative;
    }
  }

  .es-form-item:last-child {
    border-bottom: 0;
  }

  .es-form-item .item-inner {
    margin-top: 8px;
    position: relative;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
  }

  .es-form-item .item-inner:first-of-type {
    margin-top: 0;
  }

  .es-form-item .button-img {
    width: 32px;
    height: 32px;
    margin-right: 20px;
    cursor: pointer;
    border-radius: 4px;
    box-sizing: border-box;
    line-height: 36px;
    text-align: center;
    border: 1px solid transparent;
  }

  .es-form-item .button-img.block {
    width: 100%;
    position: relative;
    min-height: 32px;
    height: auto;
    padding: 10px;
    text-align: left;
  }

  .es-form-item .button-img.active {
    border-color: #fb6638 !important;
  }

  .es-form-item [type="checkbox"],
  [type="radio"] {
    box-sizing: border-box;
    padding: 0;
  }

  .es-form-item .opacity-0 {
    opacity: 0;
  }

  .es-form-item .button-img .opacity-0 {
    width: 0;
    height: 0;
    position: absolute;
  }

  .es-form-item .alignC {
    text-align: center;
  }

  .es-form-item .item {
    background: #f6f7f9;
    padding: 10px 20px 10px 10px;
    border: 1px solid #eee;
    color: #999;
    position: relative;
    margin-bottom: 20px;
  }

  .es-form-item .labeltext {
    width: 40px;
    text-align: right;
    padding-right: 8px;
    color: #666;
  }

  .es-form-item .item .delete-child {
    position: absolute;
    right: 4px;
    top: 0;
    cursor: pointer;
    font-size: 14px;
  }

  .ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .my-uploadSource {
    padding: 8px;
    border: 1px solid #e5e5e5;
    width: 150px;
    position: relative;
    cursor: pointer;
  }

  .my-uploadSource:hover .my-close-light {
    display: block;
  }

  .my-close-light {
    display: none;
    position: absolute;
    font-size: 16px;
    top: -8px;
    right: -8px;
    color: rgb(218, 217, 217);
    cursor: pointer;
  }

  //列表结束
}
</style>
